<template>
  <ElDrawer v-model="visible" size="80%" direction="ttb" :with-header="false" :lock-scroll="false">
    <div class="content">
      <ReadOnlyPurchase :purchase-bill="purchaseBill">
        <template #auditor>
          <ElSelect v-model="purchaseBill.auditor" placeholder="提交给．．．">
            <template v-for="(e, i) in dicts" :key="i">
              <template v-if="e.type === 'UserInfo'">
                <ElOption :label="e.label" :value="e.value"></ElOption>
              </template>
            </template>
          </ElSelect>
        </template>
      </ReadOnlyPurchase>

      <ElDivider></ElDivider>
      <ElButton type="primary" @click="submit()">提交</ElButton>
    </div>
    <!-- <ReadOnlyPurchase :purchase-bill="purchaseBill">
      <template #auditMsg>
        <ElInput v-model="purchaseBill.auditMsg"></ElInput>
      </template>

      <template #applier="that">
        <ElTag>{{ that.val }} {{ that.abc }}</ElTag>
        等效于
        <ElTag>{{ purchaseBill.applier }}</ElTag>
      </template>
    </ReadOnlyPurchase> -->
  </ElDrawer>
</template>
<script lang="ts">
import { PurchaseBill } from '@/entity/purchase.entity'
import { useMenuStore } from '@/stores/menu'

/**
 * 页面核心数据结构体说明文档
 *
 *
 */
// import from

export default defineComponent({
  name: 'PurchaseSubmit',
  emits: ['postSubmit'],
  props: {
    sampleP: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      sampleD: 'value',
      purchaseBill: {} as PurchaseBill,
      visible: false
    }
  },
  computed: {
    ...mapState(useMenuStore, ['dicts'])
    /* sampleC() {
      return this.sampleD + "--";
    }, */
  },
  created() {},
  mounted() {},
  methods: {
    // sampleM() {},
    show(data: PurchaseBill) {
      this.purchaseBill = data
      this.visible = true
    },
    async submit() {
      //   ElMessage.success(JSON.stringify(this.purchaseBill))
      if (!this.purchaseBill.auditor) {
        ElMessage.error('请先确定提交人')
      } else {
        const res = await axios({
          method: 'put',
          url: '/purchase/submit',
          data: this.purchaseBill
        })
        ElMessage.success('提交成功')
        this.$emit('postSubmit', 1)
        this.visible = false
      }
    }
  },
  watch: {
    // sampleP(n, o) {},
  }
})
</script>

<!--<style scoped>-->
<style lang="scss" scoped>
.content {
  width: 1200px;
  margin-left: 120px;
  // background-color: green;
}
</style>
